package com.logic.meeting.app.util;

import android.widget.EditText;

import java.lang.reflect.Method;

public class ClickUtil {

    public static final int DELAY = 1000;
    private static long lastClickTime = 0;

    public static final int DELAY2 = 2000;
    private static long lastClickTime2 = 0;

    public static boolean isNotFastClick() {
        long currentTime = System.currentTimeMillis();
        if (currentTime - lastClickTime > DELAY) {
            lastClickTime = currentTime;
            return true;
        } else {
            return false;
        }
    }

    public static void setLastClickTime() {
        lastClickTime = 0;
    }

    public static boolean isNotFastClick2() {
        long currentTime = System.currentTimeMillis();
        if (currentTime - lastClickTime2 > DELAY2) {
            lastClickTime2 = currentTime;
            return true;
        } else {
            return false;
        }
    }

    /**
     * 禁止Edittext弹出软件盘，光标依然正常显示。
     */
    public static void disableShowSoftInput(EditText editText) {
        Class<EditText> cls = EditText.class;
        Method method;
        try {
            method = cls.getMethod("setShowSoftInputOnFocus", boolean.class);
            method.setAccessible(true);
            method.invoke(editText, false);
        } catch (Exception e) {
            // TODO: 2018/8/27 处理错误
        }

    }
}